#!/usr/bin/python3
# -*- coding:utf-8 -*-
"""
    练习，编写一个Screen类，采用@property修饰函数，转换为实例属性
    请利用@property给一个Screen对象加上width和height属性，以及一个只读属性resolution：
"""


class Screen(object):

    def __init__(self):
        self.__wid = 0
        self.__heig = 0

    @property
    def width(self):
        return self.__wid

    @width.setter
    def width(self, wid):
        self.__wid = wid

    @property
    def height(self):
        return self.__heig

    @height.setter
    def height(self, heig):
        self.__heig = heig

    @property
    def resolution(self):
        return '%s x %s' % (self.__wid, self.__heig)


def main():
    scr = Screen()
    scr.width = 1080
    scr.height = 800
    print(scr.width)
    print(scr.height)
    print(scr.resolution)
    # scr.resolution = '800 x 600'    # 发生异常：AttributeError can't set attribute


if __name__ == '__main__':
    main()
